Learn R Programming

memify (version 0.1.1)

memify support functions: Extract, Update, and Replace Argument Lists of Memified Functions

Description

These functions support the use of memified functions.

Usage

arglist(f)

arglist(x) <- value

# S3 method for memified update(object, …)

Arguments

x, f, object

A memified function.

value

A named list of argument values to replace the existing argument list. An attempt will be made to coerce a non-list to a list. If successful, the coerced arglist will be used and a warning reporting the coercion will be issued. Otherwise an error will be thrown.

Tagged argument-value pairs to add to or replace existing arglist arguments.

Value

arglist() returns the existing argument list.

arglist <- value replaces the existing argument list with the (possibly coerced) new list.

update() (silently) adds additional named arguments to a function's arglist and/or changes the values of any that already exist. NULL is invisibly returned.

Warning

The update and replacement functions do not check that valid argument names are used. Invalid arguments can of course cause errors when the memified functions are subsequently invoked.

See Also

memify

Examples

Run this code
# NOT RUN {
f.m <- memify(function(a = 0, b) sin(a+b))
f.m( b = pi/4) # uses default for a
arglist(f.m)
update(f.m, a= pi/4) ## new default for a
f.m(b = -pi/4)
arglist(f.m) <- list() ## resets arglist
f.m( b = pi/4) ## The original default of a = 0 is used

## cleanup
rm(f.m)
# }

Run the code above in your browser using DataLab